package com.hdd.art.biz.painting.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hdd.art.biz.painting.entity.PaintingPraises;
import com.hdd.art.biz.painting.mapper.PaintingPraisesMapper;
import com.hdd.art.biz.painting.service.PaintingPraisesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fang
 * @since 2021-07-18
 */
@Service
public class PaintingPraisesServiceImpl extends ServiceImpl<PaintingPraisesMapper, PaintingPraises> implements PaintingPraisesService {

    @Override
    public void insert(String workId, String userId) {
        PaintingPraises praises = new PaintingPraises();
        praises.setUserId(userId);
        praises.setWorkId(workId);
        baseMapper.insert(praises);
    }


    @Override
    public boolean isPraises(String workId, String userId) {
        QueryWrapper<PaintingPraises> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        wrapper.eq("work_id",workId);
        return baseMapper.selectCount(wrapper)>0?true:false;
    }
}
